<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wiki="http://projectsexception.com/festivales/wiki"
  xmlns:bands="http://projectsexception.com/festivales/bands" xmlns:i="http://apache.org/cocoon/include/1.0">

  <xsl:param name="language" select="'en'"/>

  <xsl:template match="bands:band">
    <xsl:variable name="wikiTitle">
      <xsl:choose>
        <xsl:when test="bands:locale[@lang=$language]">
          <xsl:value-of select="translate(bands:locale[@lang=$language]/@name,' ','_')"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="translate(@name,' ','_')"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    
    <band id="{@id}" name="{@name}">
      <photoURL>
        <wiki:picture title="{$wikiTitle}"/>
      </photoURL>
      <biography>
        <wiki:content title="{$wikiTitle}" />
      </biography>
    </band>
  </xsl:template>

  <xsl:template match="node()|@*|comment()" priority="-1">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()|comment()" />
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>